<?php
namespace Amis\functions;

use Amis\Basics\AmisBasics;

class NavLinks extends AmisBasics
{
    /**
     * 名称
     * @param $label
     * @return $this
     */
    public function label($label)
    {
        $this->label = $label;
        return $this;
    }

    /**
     * @param string $to
     * @return $this
     */
    public function to(string $to)
    {
        $this->to = $to;
        return $this;
    }

    /**
     * 链接关系
     * @param string $target
     * @return $this
     */
    public function target(string $target)
    {
        $this->target = $target;
        return $this;
    }

    /**
     * 图标
     * @param string $icon
     * @return $this
     */
    public function icon(string $icon)
    {
        $this->icon = $icon;
        return $this;
    }

    /**
     * 子链接
     * @param array $children
     * @return $this
     */
    public function children(array $children)
    {
        $this->children = $children;
        return $this;
    }

    /**
     * 初始是否展开
     * @param bool $unfolded
     * @return $this
     */
    public function unfolded(bool $unfolded)
    {
        $this->unfolded = $unfolded;
        return $this;
    }

    /**
     * 是否高亮
     * @param bool $active
     * @return $this
     */
    public function active(bool $active)
    {
        $this->active = $active;
        return $this;
    }

    /**
     * 是否高亮的条件，留空将自动分析链接地址
     * @param string $activeOn
     * @return $this
     */
    public function activeOn(string $activeOn)
    {
        $this->activeOn = $activeOn;
        return $this;
    }

    /**
     * 标记是否为懒加载项
     * @param bool $defer
     * @return $this
     */
    public function defer(bool $defer)
    {
        $this->defer = $defer;
        return $this;
    }

    /**
     * 可以不配置，如果配置优先级更高
     * @param string $deferApi
     * @return $this
     */
    public function deferApi($deferApi = '')
    {
        $this->deferApi = $deferApi;
        return $this;
    }
}